﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Script.Services;
using System.Web.Services;

using ZX.WebApp;
using ZX.BLL.Extend;
using ZX.SYS.Bussiness;
namespace ZX.WebApp.Crm.BasePages
{
    public partial class StartWorkflowData : ZX.Web.UI.Controls.BasePage
    {
      
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }
        [WebMethod]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public static string WorkFlowStatr(string TableName, object KeyValue, string xWorkflowId, string xWorktaskId)
        {
            string strWorkMsg = "";
            try
            {
                if (!string.IsNullOrEmpty(TableName) && KeyValue!=null)
                {

                    if (TableName != "" && KeyValue != null)
                    {
                        ZX.EHR.Library.DatUser U = HttpContext.Current.Session["User"] as ZX.EHR.Library.DatUser;
                        string UserId = U.UserID.ToString();
                        string WorkflowInsId = Guid.NewGuid().ToString();
                        string WorktaskInsId = Guid.NewGuid().ToString();
                        ZX.SYS.Bussiness.WorkFlowStartInfo wfsi = new ZX.SYS.Bussiness.WorkFlowStartInfo();
                        if (wfsi.Start(TableName, KeyValue, xWorkflowId, xWorktaskId, WorktaskInsId, WorkflowInsId))
                        {
                            //Response.Write("更新成功");
                            ZX.WebApp.CrmWorkFlowService.WorkFlowServiceClient workflow = new ZX.WebApp.CrmWorkFlowService.WorkFlowServiceClient();
                            workflow.Start(UserId, xWorkflowId.ToString(), xWorktaskId.ToString(), WorkflowInsId.ToString(), WorktaskInsId.ToString(), workflow.GetWorkFlowNO(), "提交", "3", "缴款单", false);
                            // Response.Redirect("tooltip.aspx?worktaskInstanceId=" + WorktaskInsId);
                            strWorkMsg = "OK%@"+WorktaskInsId;
                        }
                        //Response.Write("0");
                        //return;
                    }
                    //BaseUserPage.LoadWaitPage();
                }
            }
            catch (Exception ex)
            {
                //LogData.WriteLog("平台打开启动界面错误:" + ex, lbWorkflowInsId.Text);
                strWorkMsg = "ERR%@"+ex.Message;
            }

            return strWorkMsg;
        }


    }
}